package com.midea.ai.air.ui.more.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.midea.ai.air.R;
import com.midea.ai.air.ui.more.data.BaseListItem;

import java.util.ArrayList;

/**
 * Created by ouyangdi on 2015/12/16.
 * 更多—>设置界面 ListView的Adapter
 */
public class SettingListAdapter extends ArrayAdapter<BaseListItem> {
    Context mContext;

    public SettingListAdapter(Context context, ArrayList<BaseListItem> settingListItem) {
        super(context, 0, settingListItem);
        this.mContext = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item_more, null);
        }

        BaseListItem item = getItem(position);

        TextView txtView = (TextView)convertView.findViewById(R.id.txtView_name);
        txtView.setText(item.getStrName());

        if(item.isDrawBotLine()) {
            convertView.findViewById(R.id.bottom_line).setVisibility(View.VISIBLE);
        } else if(!item.isDrawBotLine()) {
            convertView.findViewById(R.id.bottom_line).setVisibility(View.INVISIBLE);
        }

        return convertView;
    }
}
